<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper search-box-cuesList">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :xl="6" :lg="6" :md="6" :sm="24">
            <a-form-item>
              <j-input placeholder="请输入主题名称" v-model="queryParam.themeName"></j-input>
            </a-form-item>
          </a-col>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search" title="搜索" shape="circle"></a-button>
              <a-button
                type="primary"
                @click="searchReset"
                icon="reload"
                style="margin-left: 8px"
                title="重置"
                shape="circle"></a-button>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>

    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="display:flex;padding-left: 10px; align-items: center;">
        <!-- 操作按钮区域 -->
        <div class="table-operator" style="flex:1;text-align: left;margin-bottom:0">
          <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
        </div>
        <div>
          <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a style="font-weight: 600">{{
          selectedRowKeys.length }}</a>项
          <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        </div>
      </div>

      <a-table
        ref="table"
        size="middle"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">
        <img style="width:50px;heigth:50px" slot="pic" slot-scope="text, record" :src="record.mbLogoUrl"
             :preview="record.mbLogoUrl"/>
        <span slot="action" slot-scope="text, record">
          <a @click="handleEdit(record)" title="编辑"><a-icon type="edit" theme="filled"/></a>
          <a-divider type="vertical"/>
          <a-popconfirm title="确定删除吗?" @confirm="() => handleDelete(record.id)">
            <a title="删除"><a-icon type="delete" theme="filled" style="color:#ed7770"/></a>
          </a-popconfirm>
        </span>
      </a-table>
    </div>
    <!-- table区域-end -->
    <!-- 表单区域 -->
    <thmThemeInfo-modal ref="modalForm" @ok="modalFormOk"></thmThemeInfo-modal>
  </a-card>
</template>

<script>
  import ThmThemeInfoModal from './modules/ThmThemeInfoModal'
  import {
    JeecgListMixin
  } from '@/mixins/JeecgListMixin'
  import JInput from '@/components/jeecg/JInput'

  export default {
    name: 'ThmThemeInfoList',
    mixins: [JeecgListMixin],
    components: {
      ThmThemeInfoModal,
      JInput
    },
    data() {
      return {
        description: '主题信息管理页面',
        // 表头
        columns: [{
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: 'center',
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          }
        },
          // {
          //   title: '备注',
          //   align: "center",
          //   dataIndex: 'remark'
          // },
          // {
          //   title: '删除标识0-正常,1-已删除',
          //   align: "center",
          //   dataIndex: 'delFlag'
          // },
          // {
          //   title: '主题分类ID',
          //   align: "center",
          //   dataIndex: 'categoryId'
          // },
          // {
          //   title: '主题分类名称',
          //   align: "center",
          //   dataIndex: 'categoryName'
          // },
          // {
          //   title: '发起人id',
          //   align: "center",
          //   dataIndex: 'authorId'
          // },
          // {
          //   title: '发起人头像',
          //   align: "center",
          //   dataIndex: 'authorHead'
          // },
          {
            title: '发起人名称',
            align: 'center',
            dataIndex: 'authorName'
          },
          {
            title: '主题名称',
            align: 'center',
            dataIndex: 'themeName'
          },
          {
            title: '主题简介',
            align: 'center',
            dataIndex: 'themeIntroduce'
          },
          {
            title: '主题宣传图',
            align: 'center',
            dataIndex: 'mbLogoUrl',
            scopedSlots: {
              customRender: 'pic'
            }
          },
          // {
          //   title: '主题内容',
          //   align: "center",
          //   dataIndex: 'content'
          // },
          {
            title: '搜索关键词',
            align: 'center',
            dataIndex: 'keyword'
          },
          // {
          //   title: '是否发布',
          //   align: "center",
          //   dataIndex: 'isReleaseName'
          // },
          // {
          //   title: '发布日期(攻略发布时间)',
          //   align: "center",
          //   dataIndex: 'releaseTime'
          // },
          // {
          //   title: '是否置顶',
          //   align: "center",
          //   dataIndex: 'isTopName'
          // },
          {
            title: '操作',
            dataIndex: 'action',
            align: 'center',
            scopedSlots: {
              customRender: 'action'
            }
          }
        ],
        url: {
          list: '/them/thmThemeInfo/list',
          delete: '/them/thmThemeInfo/delete',
          deleteBatch: '/them/thmThemeInfo/deleteBatch',
          exportXlsUrl: 'them/thmThemeInfo/exportXls',
          importExcelUrl: 'them/thmThemeInfo/importExcel'
        }
      }
    },
    computed: {
      importExcelUrl: function () {
        return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`
      }
    },
    watch: {
      dataSource(newValue, oldValue) {
        for (let item of newValue) {
          switch (item.isRelease) {
            case 1:
              item.isReleaseName = '是'
              break
            case 2:
              item.isReleaseName = '否'
              break
            default:
              break
          }
          switch (item.isTop) {
            case 1:
              item.isTopName = '是'
              break
            case 2:
              item.isTopName = '否'
              break
            default:
              break
          }
        }
      }
    },
    methods: {}
  }
</script>
<style scoped>
  @import '~@assets/less/common.less'
</style>
